'use strict';

module.exports = app => {
    const { STRING, UUID, UUIDV4, INTEGER, DECIMAL } = app.Sequelize;

    const model = app.model.define('batch_product', {
        id: {
            type: UUID,
            defaultValue: UUIDV4,
            primaryKey: true,
            comment: 'Id',
        },
        batch_id: {
            type: UUID,
            comment: '批次Id',
        },
        customer_id: {
            type: UUID,
            comment: '客户Id',
        },
        product_id: {
            type: UUID,
            comment: '产品Id'
        },
        product_name: {
            type: STRING,
            comment: '产品名称'
        },
        product_type: {
            type: STRING,
            comment: '型号',
        },
        product_factory: {
            type: STRING,
            comment: '生产厂家',
        },
        product_unit: {
            type: STRING,
            comment: '单位',
        },
        product_category: {
            type: UUID,
            comment: '产品分类',
        },
        num: {
            type: INTEGER,
            comment: '数量'
        },
        sale_price: {
            type: DECIMAL(10, 2),
            comment: '销售价格'
        },
        sale_amount: {
            type: DECIMAL(10, 2),
            comment: '销售价格'
        },
        remark: {
            type: STRING,
            comment: '备注',
        },
    }, {
            tableName: 'batch_product',
            comment: '批次产品表',
        });

    return model;
};
